/********************************************/
  // Creation History
  // --------------------------------------------------------------
  //	Company:			HTHK
  //	NAME:				RateSearch.java
  //    Title   :		find Rate Records, return one or more records
  //                         
  //	FUNCTION:			
  //	BY:				Poly Li
  //	DATE:				2004-01-09
  // --------------------------------------------------------------
/*********************************************/

package tss.rate;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

import tss.common.DBServlet2;

/**
 * A Class class.
 * <P>
 * @author HTHK
 */
public class RateSearch
  extends DBServlet2 {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      //New A Rate
      RateBean Rate = RateProcess.createBean();
      //RateBean OvertimeRate = RateProcess.createBean();

      //Get search condition
     Rate.setGrade(request.getParameter("grade"));
 //    Rate.setOvertime_rate(request.getParameter("overtimeRate"));

	  //Get the results
      RateBean[] Rates = RateProcess.find(this.getConnection(),Rate);
//      RateBean[] OvertimeRates = RateProcess.find(this.getConnection(),Rate);
      //Find nothing
      if (Rates==null || Rates.length==0)   // || OvertimeRates==null || OvertimeRates.length==0)
      {
          message.setMessage("No record, please input another criteria.");
          return "tss/rate/RateSearch.jsp";
      }
      //Find a record
      else if (Rates.length==1)
      {
          request.setAttribute("Rate",Rates[0]);
       //   request.setAttribute("OvertimeRate",OvertimeRates[0]);
          return "tss/rate/Rate.jsp?formAction=Update";
      }
      //find more than one records
      else
      {
          request.setAttribute("Rates",Rates);
       //   request.setAttribute("OvertimeRate",OvertimeRates);
          return "tss/rate/RateList.jsp";
      }
  }
}


